package jpb.module.dao.organize;

import jpb.module.dao.organize.mapper.OrganizeMapper;
import jpb.module.daomain.organize.Organize;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by haol on 2017/4/1.
 */
@Repository
public class OrganizeDao {
        private Logger logger = LoggerFactory.getLogger(Organize.class);
        @Autowired
        private OrganizeMapper mapper;


        public void add(Organize organize) {
                try {
                        mapper.add(organize);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                }
        }


        public void complete(Organize organize) {
                try {
                        mapper.complete(organize);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                }
        }
        public Organize getByMark(String mark) {
                try {
                       Organize organize = mapper.getByMark(mark);
                        return this.get(organize.getId());
                } catch (Exception e) {
                        logger.error(e.getMessage());
                        return null;
                }
        }

        public void delete(String id) {
                try {
                        this.deleteManOrg(id);
                        mapper.delete(id);
                } catch (Exception e) {
                        logger.error(e.getMessage());

                }
        }



        public void deleteManOrg(String id) {
                try {
                        mapper.deleteManOrg(id);
                } catch (Exception e) {
                        logger.error(e.getMessage());

                }
        }

        public Organize get(String id) {
                try {
                        Organize organize = mapper.get(id);
                        return organize;
                } catch (Exception e) {
                        logger.error(e.getMessage());
                        return null;
                }
        }


        public List<Organize> getByMid(String mid) {
                try {
                        return mapper.getByMid(mid);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                        return null;
                }
        }
        public List<Organize> getByNum(String memberNum) {
                try {
                        return mapper.getByNum(memberNum);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                        return null;
                }
        }

        public void updateTime(String id, String time) {
                try {
                        mapper.updateTime(id, time);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                }
        }

        public void updateLogo(Organize organize) {
                try {
                        mapper.updateLogo(organize);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                }
        }

        public List<Organize> getPubOrgByNum(String num){
                try {
                        return mapper.getPubOrgByNum(num);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                        return null;
                }
        }
        public List<Organize> getPubOrg( ){
                try {
                        return mapper.getPubOrg();
                } catch (Exception e) {
                        logger.error(e.getMessage());
                        return null;
                }
        }

        public void clearFollow(String oid){
                try {
                        mapper.clearFollow(oid);
                }catch (Exception e){
                        logger.error(e.getMessage());
                }
        }

}
